package com.guojian.common.proxy;

import java.lang.reflect.Proxy;

public class ProxyTest {

	public static void main(String[] args) {

		ProxyFactory jdkfactory = new JdkProxyFactory();
		Pbean bean = new Pbean();

		IPbean pbeanProxy = jdkfactory.createProxy(bean);
		System.out.println(pbeanProxy.say("ABVVVVV"));
		
		
		
		
	}

	public static void main1(String[] args) {

		Pbean pbean = new Pbean();

		/*
		System.out.println(ProxyFactory.create());
		
		Pbean pbeanProxy = ProxyFactory.create().proxy(new Pbean(), PbeanAspect.class);
		
		System.out.println(pbeanProxy.say());
		
		IPbean pp = (IPbean) Proxy.newProxyInstance(pbean.getClass().getClassLoader(), pbean.getClass().getInterfaces(), new PbeanInvacationHandler(pbean));
		
		System.out.println(pp.say());*/

		/*Pbean2 p2 = new Pbean2();
		Pbean2 pps = (Pbean2) org.springframework.cglib.proxy.Proxy.newProxyInstance(p2.getClass().getClassLoader(), p2.getClass().getInterfaces(), new SpringInvocationHandler(p2));
		System.out.println(pps);*/

		Object object = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { IPbean.class }, new JdkProxyHandler(new Pbean()));

		IPbean pbeanproxy = (IPbean) object;

		System.out.println(pbeanproxy.say("guojian"));

		System.out.println("========================");

		for (Class<?> c1 : Pbean.class.getInterfaces()) {
			System.out.println("===" + c1);
		}

		for (Class<?> c2 : IPbean.class.getInterfaces()) {
			System.out.println("---" + c2);
		}

	}

}
